<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户提现记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>快手号：</label>
                                <input type="text" id="userName" name="userName"/>
                            </li>
                            <li>
                                <label>用户ID：</label>
                                <input type="text" id="userId" name="userId"/>
                            </li>
                            <!--<li>
                                <label>提现金额：</label>
                                <input type="text" name="withdrawMoney"/>
                            </li>-->
                           <!-- <li>
                                <label>收款码：</label>
                                <input type="text" name="withdrawPic"/>
                            </li>
                            <li>
                                <label>转账凭证：</label>
                                <input type="text" name="payPic"/>
                            </li>-->
                            <li>
                                <label>状态：</label>
                                <select name="status" id="status">
                                    <option value="">所有</option>
                                    <option value="申请">申请</option>
                                    <option value="已转账">已转账</option>
                                    <option value="失败">失败</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="whzj:userwithdraw:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="whzj:userwithdraw:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="whzj:userwithdraw:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="whzj:userwithdraw:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
                <div>
                    <label>提现总金额：</label>
                    <input type="text" id="sumMoney" name="sumMoney"/>
                </div>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('whzj:userwithdraw:edit')}]];
        var removeFlag = [[${@permission.hasPermi('whzj:userwithdraw:remove')}]];
        var prefix = ctx + "whzj/userwithdraw";

        $(function() {
            var options = {
                url: prefix + "/listBegin",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户提现记录",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'userId',
                    title: '用户ID'
                },{
                    field: 'userName',
                    title: '快手号'
                },
                    {
                        field: 'withdrawBefore',
                        title: '提现前金额'
                    },
                {
                    field: 'withdrawMoney',
                    title: '提现金额'
                },
                    {
                        field: 'withdrawAfter',
                        title: '提现后金额'
                    },
                {
                    field: 'withdrawPic',
                    title: '收款码',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value, '/profile/avatar');
                    }
                },
                {
                    field: 'payPic',
                    title: '转账凭证',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value, '/profile/avatar');
                    }
                },
                {
                    field: 'status',
                    title: '状态'
                },
                {
                    field: 'reduceReason',
                    title: '拒绝原因'
                },{
                        field: 'createTime',
                        title: '申请时间'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status == '申请'){
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="review(\'' + row.id + '\')"><i class="fa fa-remove"></i>转账</a>');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="reviewDis(\'' + row.id + '\')"><i class="fa fa-edit"></i>拒绝</a> ');
                        }
                        return actions.join('');
                    }
                }],
                onLoadSuccess: function () {
                    //统计总额
                    $.ajax({
                        type: "post",
                        url: prefix + "/getCount?type=begin&userName="+$("#userName").val()+"&status="+$("#status").val(),
                        success: function(r) {
                            debugger;
                            $("#sumMoney").val(r.data.sumMoney);
                        }
                    });
                }
            };
            $.table.init(options);
        });

        function review(id) {
            $.modal.confirm("确认转账吗？", function(e) {
                debugger;
                if(e){
                    debugger;
                    $.ajax({
                        type: "post",
                        url:  prefix + "/reviewSucc?id="+id,
                        success: function(r) {
                            $.modal.msgSuccess("请进行线下转账");
                            $.modal.msgReload();
                        }
                    });
                }
            });

        }

        function reviewDis(id) {
            debugger;
            $.modal.open('审批拒绝', prefix + "/review/"+id, '900', '320');
        }
    </script>
</body>
</html>